// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App'
import router from './router'
import Vuex from 'vuex'
import store from './vuex/store_index'
import axios from 'axios'
import {mapState, mapMutations,mapActions,mapGetters} from 'vuex'

Vue.prototype.$ajax = axios

Vue.use(Vuex)
Vue.use(VueRouter)
Vue.config.productionTip = false// 来关闭生产模式下给出的提示

router.beforeEach((to, from, next) => {
  if(store.getters.Loading_show == false){
    store.commit('Change_loading_show')
  }
  if (to.meta.requireAuth) {
    if (sessionStorage.getItem("user_login") == "true") {
       next()
    }
    else {
      next({
        path: '/'
      })
    }
  }else{
    if (sessionStorage.getItem("user_login") == "true") {
      next({
        path: '/index'
      })
    }else{
      next();
    }
   }
})



/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {App}
})
